#!/usr/bin/env python
# -*- coding: utf8 -*-

'''
Created on 2011-7-26

京东价格图片识别模块

@author: zhongfeng
'''

import ImageFilter, ImageChops
from captcha_price import *
from coo8.coo8_feature2 import COO8_FEATURES_MAP
import Image
import itertools
import re
import time

try:
    import psyco
    psyco.full()
except ImportError:
    pass

class CaptchaProfile_coo8(CaptchaProfile):
    def __init__(self,features_map = COO8_FEATURES_MAP):
        super(CaptchaProfile_coo8,self).__init__(features_map)
        
    def __new__(cls,features_map = COO8_FEATURES_MAP):
        return super(CaptchaProfile_coo8, cls).__new__(cls,features_map)
    
    def split(self, im,top = 4,bottom = 16):
        return super(CaptchaProfile_coo8,self).split(im,top,bottom)

def captcha_coo8(filename):
    return captcha(filename, CaptchaProfile_coo8())

def test():
    print CaptchaProfile_coo8(r'c:\gp359329,2.png')
    
import os  
curModDir = os.path.dirname(os.path.abspath(__file__))
testFilePath = os.path.join(curModDir, 'test_resources')
if __name__ == '__main__':
    fileName = os.path.join(testFilePath, "125487,1.png")
    print captcha_coo8(fileName)
    
#    it1 = im.crop((3, 4, 13, 16))
#    print cia.GetBinaryMap(it1),'\n'
#    it2 = im.crop((15,4,24,16))
#    print cia.GetBinaryMap(it2)
#    print '+++++++++'
#    it2 = im.crop((25, 4, 34, 16))
#    it3 = im.crop ((36,4,45,16))
#    #it3 = im.crop((35, 4, 37, 16))
#    it4 = im.crop((38, 4, 47, 16))
#    it5 = im.crop((48, 4, 57, 16))
#    #it6 = im.crop((51, 3, 57, 11))
#    #it7 = im.crop((59, 3, 65, 11))
#    multilist = [[0 for col in range(5)] for row in range(3)]
#    print '\n'.join(( str(t) for t in multilist))
    #profile = CaptchaProfile_360Buy()
    
    #print captcha_360buy(r'c:\6.png')
        
        
